// pages/firstpage/kaifaqu/index.js
import {
  ApiRootUrl,
  apiList
} from '../../../config/index.js'
import Toast from '../../../@vant/weapp/toast/toast';
import Dialog from '../../../@vant/weapp/dialog/dialog';
import {
  IMG_PATH
} from '../../../config/index.js'
import {
  request,login
} from "../../../utils/util.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight:"",
    IMG_PATH:IMG_PATH,
    isBottom:0
  },
  toBottom(e){
    let index = e.currentTarget.dataset.index
    console.log(index)
    this.setData({
      isBottom:index
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
    })
    this.getMessage()
    // this.showKaika()
  },
  
  showKaika(){
                wx.showModal({
              title: '提示',
              content: '您是否有交通银行储蓄卡？',
              confirmText:"是",
              cancelText:"否",
              success: function (res) {
                  if (res.confirm) {
                      console.log('用户点击是');
                      wx.navigateTo({
                        url: '/pages/firstpage/bankcard/bankcard?type=1',
                      })
                  } else if (res.cancel) {
                      console.log('用户点击否');
                      wx.navigateTo({
                        url: '/pages/firstpage/bankcard/bankcard?type=2',
                      })
                  }
              }
          })
  },
  getMessage(){
    let self = this;
    let params={
      pageSize:20,
      pageNum:1
    }
    wx.request({
      url: `${ApiRootUrl}/consult/queryEmployeeMessage`,
      method: 'POST',
      header: {
        'content-type': 'application/json; charset=utf-8',
        'cookie': wx.getStorageSync("sessionid")
      },
      data:params,
      success(res) {
        if(res.data.code == 20000){
          console.log(res.data);
        }else{
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: res.data.message,
            mask:true
          });
        }
      },
      fail(res){
        Toast({
          duration: 3000,
          forbidClick: true,
          type: 'fail',
          message: '网络已断开',
        });
      }
    })
  },
  clickImg(){
    console.log('点击');
    Toast.fail({
      message: '开发中，敬请期待！',
    });
  },
  backClick() {
    wx.navigateBack();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})